﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using PegasCompany.Data;
using PegasCompany.SiteMembership;
using PegasCompany.Tools;

namespace PegasCompany.Master
{
    public partial class ViewMain : System.Web.UI.MasterPage
    {
        private List<SiteContent> GetContent(EnumHelper.ListContentType targetContent, int? count)
        {
            return SiteContent.ListAllContent((int)targetContent, null, count);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                List<Slide> slideList = Slide.Search();
                rptSlider.DataSource = slideList;
                rptSlider.DataBind();

                rptSlideLine.DataSource = slideList;
                rptSlideLine.DataBind();

                List<SiteContent> lastMessagesContent = GetContent(EnumHelper.ListContentType.News, 5);
                {
                    if (lastMessagesContent != null)
                    {
                        rptLastMessages.DataSource = lastMessagesContent;
                        rptLastMessages.DataBind();
                    }
                }

                List<SiteContent> lstInfoBlock = SiteContent.GetInfoBlockList((int)EnumHelper.ContentType.Block1, (int)EnumHelper.ContentType.Block2, (int)EnumHelper.ContentType.Block3);
                if (lstInfoBlock != null)
                {
                    rptInfoBlock.DataSource = lstInfoBlock;
                    rptInfoBlock.DataBind();
                }

                //rptBottomMenu.DataSource = smiList;
                //rptBottomMenu.DataBind();

                //List<SiteContent> sc = SiteContent.ListAllContent((int)EnumHelper.ContentType.License, true, true);
                //if (sc != null && sc.Count > 0)
                //{
                //    SiteContent targetSiteContent = sc.SingleOrDefault();
                //    if (targetSiteContent != null)
                //    {
                //        //lLicense.Text = targetSiteContent.Content;
                //    }
                //}
            }
        }
    }
}